Moving a site collection to another content database
is a task that is incumbent upon a SharePoint Farm Administrator. There
are several reasons why this may need to be done:
This is going to be shown via PowerShell. The
strength of this method is that it facilitates the scripting of tasks
that are considered repetitive. In this way, administrators can create
scripts to move more than one site collection at a time.
Getting ready
User must have access to one of the servers running PowerShell 2.0 and should be a member of the WSS_ADMIN_WPG&; on the local computer. User must also be a member of the db_owner database role&; and the SharePoint_Shell_Access role&; in the following databases:
There must be an existing site collection that is
going to be moved. In addition, a destination content database must be
set up within a web application, prior to performing this recipe.
For this recipe to work, the content database and the
site collection must be on the same SQL server and in the same web
application.
How to do it...
Click on the Start button on the web front-end.
Under All Programs, navigate to the Microsoft SharePoint 2010 Products folder.
Right-click SharePoint 2010 Management Shell and select the Run as Administrator option. The PowerShell console will appear.
Type in the following command into the console window:
Move-SPSite -identity <site collection URL> -destinationdatabase <content database>
Press the Enter key.
A prompt will appear asking for confirmation. It will look similar to the following:&;
Type in Y and press the Enter key.
Perform an iisreset operation&; in the command prompt window.
How it works...
PowerShell&; is a command line scripting language that has access to the SharePoint object model.
In this example under the web application, occupying Port 80, there are two content databases:
Wss_content
Wss_content_1
A site collection named mtsite was created under the content database named wss_content. The URL is (shown in the preceding figure): http://2008server/sites/mtsite.
The site collection was moved via PowerShell to the wss_content_1 database. Afterwards, an IISRESET was done, which is necessary to implement the change.
There's more...
One of the reasons behind the need to migrate a site
collection is its size. The following is a simple PowerShell command to
ascertain the size of a site collection:
Get-SPSiteAdministration -Identity <site URL> .DiskUsed